/*
 * redmicro all Copyright (c)
 */

/**
 * Created by seeker910 on 2015/10/17.
 */
Rsd.define('Rsd.Faith.pages.BizZiJinShiYongFenTanListPage', {
    extend: 'Rsd.Faith.pages.ListPage',
    requires: ['Rsd.Faith.controls.XiaoQuInput', 'Rsd.Faith.controls.SuoShuQiInput'],
    xtype: 'list-fengtan',
    border: false,
    tabTitle: '资金使用分摊列表',
    titleField:'shenqingdanhao',
    searchColumns:[
        {name:'SuoShuQi',text:'所属期',width:250,xtype:'ctrl-suoshuqi'},
        {name:'ShenQingDanHao',text:'使用申请单号',width:250},
        {name:'BoFuBianHao',text:'拨付编号',width:250},
        {name:'FangWuBianHao',text:'房屋编号',width:250}
        ],
    "modelType": "UsingZiJinShiYongFenTanBiaoModel",
    "formFields": [
        {
            "name": "BoFuBianHao",
            "label": {
                "text": "拨付编号",
                "width": 80
            },
            "dataindex": "bofubianhao",
            "index": 0,
            "xtype": "text"
        },
        
        {
            "name": "FenTanJinE",
            "label": {
                "text": "分摊金额",
                "width": 80
            },
            "dataindex": "fentanjine",
            "index": 0,
            "xtype": "number",
            "format": "0.00"
        },
        {
            "name": "ShenQingDanHao",
            "label": {
                "text": "申请单号",
                "width": 80
            },
            "dataindex": "shenqingdanhao",
            "index": 0,
            "xtype": "text"
        },
        {
            "name": "FenTanRiQi",
            "label": {
                "text": "分摊日期",
                "width": 80
            },
            "dataindex": "fentanriqi",
            "index": 0,
            "xtype": "date",
            "format": "yyy-MM-dd"
        },
        {
            "name": "FenTanHouYuE",
            "label": {
                "text": "分摊后余额",
                "width": 80
            },
            "dataindex": "fentanhouyue",
            "index": 0,
            "xtype": "number",
            "format": "0.00"
        },
        {
            "name": "FangWuBianHao",
            "label": {
                "text": "房屋编号",
                "width": 80
            },
            "dataindex": "fangwubianhao",
            "index": 0,
            "xtype": "text"
        },
        {
            "name": "ZhuangTai",
            "label": {
                "text": "状态",
                "width": 80
            },
            "dataindex": "zhuangtai",
            "index": 0,
            "xtype": "enum",
            "enum": {
                "name": "Rsd.Faith.Core.FenTanZhuangTai",
                "valueMember": "code",
                "items": [
                    {
                        "code": "DJ",
                        "value": 0,
                        "text": "未入账"
                    },
                    {
                        "code": "RZ",
                        "value": 1,
                        "text": "已入账"
                    }
                ]
            }
        },
        {
            "name": "Remark",
            "label": {
                "text": "备注",
                "width": 80
            },
            "dataindex": "remark",
            "index": 200,
            "xtype": "text"
        }
    ],
    "gridColumns": [
        {
            "text": "序号",
            "xtype": "index",
            "width": 40,
            "sortable": true,
            "index": 0
        },

        {
            "name": "ShenQingDanHao",
            "text": "申请单号",
            "sortable": true,
            "index": 0,
            "width": 150,
            "nobr": true
        },
        {
            "name": "SuoShuQi",
            "dataIndex": "SuoShuQi",
            "sortable": false,
            "text": "所属期",
            align:'center',
            "index": 20,
            "exist": true,
            "xtype": "string",
            "width": 80,
            "nobr": true
        },
        {
            "name": "HuaBoBianHao",
            "text": "拨付编号",
            "sortable": true,
            "index": 0,
            "width": 150,
            "nobr": true
        },
        {
            "name": "FangWuBianHao",
            "text": "房屋编号",
            "sortable": true,
            "index": 0,
            "width": 150,
            "nobr": true
        },
        {
            "name": "FenTanJinE",
            "text": "分摊金额",
            "sortable": true,
            "index": 0,
            "xtype": "number",
            "width": 100,
            "precision": 2
        },
        {
            "name": "FenTanRiQi",
            "text": "分摊日期",
            "sortable": true,
            "index": 0,
            "xtype": "date",
            "formatString": "yyyy-MM-dd",
            "width": 100
        },
        {
            "name": "FenTanHouYuE",
            "text": "分摊后余额",
            "sortable": true,
            "index": 0,
            "xtype": "number",
            "width": 100,
            "precision": 2
        },
        {
            "name": "ZhuangTai",
            "text": "状态",
            "sortable": true,
            "index": 0,
            "align":'center',
            "width": 80,
            "xtype": "enum",
           "enum": {
            "name": "Rsd.Faith.Core.FenTanZhuangTai",
            "valueMember": "code",
            "items": [
                {
                    "code": "DJ",
                    "value": 0,
                    "text": "未入账"
                },
                {
                    "code": "RZ",
                    "value": 1,
                    "text": "已入账"
                }
            ]
        },
            "nobr": true
        },
        {
            "name": "Remark",
            "text": "备注",
            "index": 200,
            "width": 50,
            "nobr": true
        }
    ],
    templateCols: [
        {
            name: 'edit',
            text: '操 作',
            nobr:true,
            xtype: 'template',
            format:'templateFormat'
        },
        {
            name: 'space',
            text: '',
            xtype: 'template',
            width: 5,
            hideable: false,
            sortable: false
        }
    ],
    /*
     * */
    constructor: function (config) {
        config = config || {};
        Rsd.apply(this, config);
    },

    /*
     * */
    xiaoQuFormat:function fanWuFormat(row)
    {
        var  _link = document.createElement('a');
        _link.href='#';
        _link.innerHTML = row['xiaoqubianhao'];
        $(_link).click (function(){alert('小区编号：' + row['xiaoqubianhao']);} );
        return [_link] ;
    },
    /*
     * */
    templateFormat:function templateFormat(row){

        var  btn1 = document.createElement('a');
        btn1.href='#';
        btn1.title ="冲帐"
        btn1.innerHTML = '冲帐';
        $(btn1).click (function(){
            var page = Rsd.create('Rsd.Faith.dialogs.BizZiJinShiYongFenTanDialog',{data:row});
            page.showDialog();}
        );




        if(row['zhuangtai']=='已入账')
        {
            return [$('<span>&nbsp;&nbsp;</span>')[0],btn1,$('<span>&nbsp;&nbsp;</span>')[0]] ;
        }

    }

});

